import {ArgumentMetadata, BadRequestException, Inject, PipeTransform} from '@nestjs/common'
export class FileSizeValidationPipe implements PipeTransform {
    transform(value: any, metadata: ArgumentMetadata): any {
        // 定义文件最大的大小
        const maxSize = 1024 * 1024
        // 如果文件超出最大值抛出异常
        if(value.size > maxSize) {
            throw new BadRequestException('Max size is less than maxSize')
        }
        return value;
    }
}
